
let app = new Vue({
    el: '#app',
    data() {
        return {
            form: {},
            data: [],
            option: {
                align: 'center',
                menuAlign: 'center',
                column: [
                    {
                        label: '名称',
                        prop:'remark'
                    },
                    {
                        label: "是否自动生成地址",
                        prop: "auto",
                        type: "switch",
                        hide:true,
                        dicData:[{
                            label: '否',
                            value:10
                        }, {
                            label: '是',
                            value: 20
                        }]
                    },
                    {
                        label: 'Ip地址',
                        prop: 'ip',
                        width:150
                    }, {
                        label: '端口',
                        prop: 'port',
                        width:150
                    },
                    {
                        label: '用户名',
                        prop: 'userName',
                        width:150
                    }, {
                        label: '密码',
                        prop: 'password',
                        hide:true,
                        width:150
                    }, {
                        label: '通道',
                        prop: 'channel',
                        width:150
                    },
                    {
                        label: '流地址',
                        prop: 'url',
                        span:24
                    },
                    {
                        label:'状态',
                        prop:'status'
                    }
                ]
            }
        }
    },
    methods: {
        rowSave(row, done, loading) {

            axios.post('/camera', row).then(()=>{
                this.onLoad();
                this.$message({
                    type: "success",
                    message: "操作成功!"
                });
                done();
            })
        },
        rowDel(row) {
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    return axios.delete(`/camera/${row.id}`);
                })
                .then(() => {
                    this.onLoad();
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                });
        },
        onLoad() {
            axios.get('/camera/list').then(res => {
                this.data = res.data
            })
        },
        connect(row){
            axios.post('/camera/connect/'+row.id)
        }
    }
})
